
public class MemoryTest {
	public static void main(String[] args) throws InterruptedException {

		long j;
		System.gc();
		j = Runtime.getRuntime().freeMemory();
		int[] ar = new int[1000];
		System.gc();
		ar.hashCode();
		System.out.println(j-Runtime.getRuntime().freeMemory());
		Thread.sleep(1000);
		System.gc();
		j = Runtime.getRuntime().freeMemory();
		int[] ar1 = new int[1000];
		System.gc();
		ar1.hashCode();
		System.out.println(j-Runtime.getRuntime().freeMemory());
		Thread.sleep(1000);
		System.gc();
		j = Runtime.getRuntime().freeMemory();
		int[] ar2 = new int[1000];
		System.gc();
		ar1.hashCode();
		System.out.println(j-Runtime.getRuntime().freeMemory());
	}
}
